﻿<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" >

	<ResourceDictionary.MergedDictionaries>
		<ResourceDictionary Source="..\Shared.xaml" />
	</ResourceDictionary.MergedDictionaries>

	<ControlTemplate x:Key="ExpanderToggleButton" TargetType="{x:Type ToggleButton}">
		<Grid>
			<!--Border
        Name="Border"
        Background="{DynamicResource VOColor11}"
        CornerRadius="1"/-->
			<Border
			  Name="BorderOver"
			  Background="{DynamicResource VOColor02}"
			  CornerRadius="1"
			  Opacity="0"/>
			<Path
			  Name="Arrow"
			  Fill="{DynamicResource VOColorIcon}"
			  HorizontalAlignment="Center"
			  VerticalAlignment="Center"
			  Data="M 0 0 L 4 4 L 8 0 Z"/>
		</Grid>
		<ControlTemplate.Triggers>
			<Trigger Property="ToggleButton.IsMouseOver" Value="True">
				<Trigger.ExitActions>
					<BeginStoryboard>
						<Storyboard>
							<Storyboard.Children>
								<DoubleAnimation To="0" Duration="00:00:00.4000000" Storyboard.TargetName="BorderOver" Storyboard.TargetProperty="Opacity" />
							</Storyboard.Children>
						</Storyboard>
					</BeginStoryboard>
				</Trigger.ExitActions>
				<Trigger.EnterActions>
					<BeginStoryboard>
						<Storyboard>
							<Storyboard.Children>
								<DoubleAnimation To="1" Duration="00:00:00.4000000" Storyboard.TargetName="BorderOver" Storyboard.TargetProperty="Opacity" />
							</Storyboard.Children>
						</Storyboard>
					</BeginStoryboard>
				</Trigger.EnterActions>
			</Trigger>

			<!--Trigger Property="IsPressed" Value="true">
        <Setter TargetName="Border" Property="Background" Value="#FFAAAAAA" />
      </Trigger-->
			<Trigger Property="IsChecked" Value="true">
				<Setter TargetName="Arrow" Property="Data" Value="M 0 4 L 4 0 L 8 4 Z" />
			</Trigger>
		</ControlTemplate.Triggers>
	</ControlTemplate>

	<Style x:Key="{x:Type Expander}" TargetType="{x:Type Expander}">
		<Setter Property="FocusVisualStyle" Value="{x:Null}" />
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Expander}">

					<ControlTemplate.Resources>
						<Storyboard x:Key="Timeline1">
							<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:0.25" Storyboard.TargetName="ExpandSite" Storyboard.TargetProperty="(FrameworkElement.LayoutTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
								<SplineDoubleKeyFrame KeyTime="00:00:0.25" Value="1"/>
							</DoubleAnimationUsingKeyFrames>
						</Storyboard>
						<Storyboard x:Key="Timeline2">
							<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.45" Storyboard.TargetName="ExpandSite" Storyboard.TargetProperty="(FrameworkElement.LayoutTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
								<SplineDoubleKeyFrame KeyTime="00:00:0.45" Value="0"/>
							</DoubleAnimationUsingKeyFrames>
						</Storyboard>
					</ControlTemplate.Resources>

					<Grid Margin="0,0,0,5">
						<Grid.RowDefinitions>
							<RowDefinition Height="Auto"/>
							<RowDefinition Name="ContentRow" Height="0"/>
						</Grid.RowDefinitions>

						<Border x:Name="Border" Grid.RowSpan="2" Background="{DynamicResource VOColor11}" CornerRadius="1" Opacity="0.5"/>

						<Grid>
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="*" />
								<ColumnDefinition Width="20" />
							</Grid.ColumnDefinitions>
							<ContentPresenter Grid.Column="0" Margin="1" ContentSource="Header" RecognizesAccessKey="True" />
							<ToggleButton
									  Grid.Column="1"
									  IsChecked="{Binding Path=IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
									  OverridesDefaultStyle="True"
									  Template="{StaticResource ExpanderToggleButton}"
									  Margin="1"/>
						</Grid>

						<Border Name="Content" Grid.Row="1" Margin="2,2,2,2">
							<ContentPresenter Focusable="False" Visibility="Visible" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" x:Name="ExpandSite" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
								<ContentPresenter.LayoutTransform>
									<TransformGroup>
										<ScaleTransform ScaleX="1" ScaleY="1"/>
										<SkewTransform AngleX="0" AngleY="0"/>
										<RotateTransform Angle="0"/>
										<TranslateTransform X="0" Y="0"/>
									</TransformGroup>
								</ContentPresenter.LayoutTransform>
							</ContentPresenter>
						</Border>

					</Grid>

					<ControlTemplate.Triggers>
						<Trigger Property="IsExpanded" Value="False">
							<Trigger.EnterActions>
								<BeginStoryboard Storyboard="{StaticResource Timeline2}"/>
							</Trigger.EnterActions>
							<Trigger.ExitActions>
								<BeginStoryboard Storyboard="{StaticResource Timeline1}"/>
							</Trigger.ExitActions>
						</Trigger>
						<Trigger Property="IsExpanded" Value="True">
							<Setter TargetName="ContentRow" Property="Height" Value="{Binding ElementName=Content,Path=DesiredHeight}" />
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

</ResourceDictionary>